﻿using Engine;
using Engine.Graphics;
using Game;

namespace Mekiasm
{
    public class EmittedLight : Item
    {
        public static int Index;

        public EmittedLight() : base("发光空气块")
        {
            
        }
        public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
        {

        }
        public override bool IsVisible(int value)
        {
            return false;
        }
        public override bool OnUse(Ray3 aim, ComponentMiner componentMiner, TerrainRaycastResult? raycast)
        {
            return false;
        }
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            return new BlockPlacementData() { Value = ILibrary.setExtraData(value, 15), CellFace = raycastResult.CellFace };
        }
        public override void GenerateTerrainVertices(Block block, BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
        {
        }
        public override int GetEmittedLightAmount(int value)
        {
            return ILibrary.getExtraData(value);
        }
        public override bool IsFaceTransparent(SubsystemTerrain subsystemTerrain, int face, int value)
        {
            return true;
        }
        public override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, MovingBlock value)
        {
            return new BoundingBox[] { new BoundingBox() };
        }
        public override BoundingBox[] GetCustomInteractionBoxes(SubsystemTerrain terrain, MovingBlock value)
        {
            return new BoundingBox[] { new BoundingBox() };
        }
        public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
        {
            if (!LightSystem.valuePairs.TryGetValue(new Point3(x, y, z), out LightPoint light))
            {
                ILibrary.SubsystemTerrain.ChangeCell(x, y, z, 0);
            }
        }
    }
}
